﻿using Microsoft.Xna.Framework;

namespace EuphoricEngine3D.Components
{
    public interface I3DComponent
    {
        Vector3 Position { get; set; }
        
        Vector3 EulerRotation { get; set; }
        
        Matrix Rotation { get; set; }
        
        Vector3 Scale { get; set; }

        BoundingBox BoundingBox { get; }
    }

    public interface I2DComponent
    {
        Rectangle Rectangle { get; set; }
    }

    public enum ComponentType
    {
        Component2D,
        Component3D,
        Both,
        All
    }

    public abstract class ComponentPredicate
    {
        public abstract bool IsComponentEligible(Component Component);
    }

    public class ComponentTypePredicate : ComponentPredicate
    {
        ComponentType Type;

        public ComponentTypePredicate(ComponentType Type)
        {
            this.Type = Type;
        }

        public override bool IsComponentEligible(Component Component)
        {
            if (Type == ComponentType.Both)
            {
                if (Component is I2DComponent || Component is I3DComponent)
                    return true;
            }
            else if (Type == ComponentType.Component2D)
            {
                if (Component is I2DComponent)
                    return true;
            }
            else if (Type == ComponentType.Component3D)
            {
                if (Component is I3DComponent)
                    return true;
            }
            else
                return true;

            return false;
        }
    }
}